Skip to content

test: implement tests for application update functionality#2562

Merged
iamitprakash merged 17 commits intodevelopfrom
anuj/application-edit-test
Feb 11, 2026
Merged

test: implement tests for application update functionality#2562
iamitprakash merged 17 commits intodevelopfrom
anuj/application-edit-test

Conversation

@AnujChhikara
Copy link
Contributor

@AnujChhikara AnujChhikara commented Jan 29, 2026

Date: 30 Jan 2026

Developer Name: @AnujChhikara


Issue Ticket Number

Description

  • Added integration tests for the PATCH /applications/:applicationId endpoint, covering various scenarios including successful updates, validation errors, and authorization checks.
  • Enhanced unit tests for the applications controller to validate update logic and error handling.
  • Introduced validation tests for application update data to ensure proper request structure and content.
  • Updated application model tests to verify correct behavior for update operations under different conditions.

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Test Coverage

Screenshot 1 image image

…ror handling

- Added a new error message for editing applications too soon.
- Implemented a function to build the update payload for applications.
- Updated the application update logic to include user authorization and time-based restrictions.
- Refactored the application validator to include comprehensive validation for update data.
- Adjusted routes to use the new validation function for application updates.
- Added integration tests for the PATCH /applications/:applicationId endpoint, covering various scenarios including successful updates, validation errors, and authorization checks.
- Enhanced unit tests for the applications controller to validate update logic and error handling.
- Introduced validation tests for application update data to ensure proper request structure and content.
- Updated application model tests to verify correct behavior for update operations under different conditions.
@AnujChhikara AnujChhikara self-assigned this Jan 29, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR adds comprehensive test coverage for the PATCH /applications/:applicationId endpoint across integration, controller, middleware, and model layers. Tests verify successful updates, authorization checks, ownership validation, 24-hour edit conflict detection, and field validation rules.

Changes

Cohort / File(s) Summary
Integration Tests
test/integration/application.test.ts
New test suite for PATCH /applications/:applicationId covering successful updates, 400/401/404/409 error responses, empty body validation, disallowed fields, invalid imageUrl, missing application, unauthenticated requests, unauthorized ownership, and 24-hour edit conflict detection.
Controller Unit Tests
test/unit/controllers/applications.test.ts
Extended updateApplication controller tests with separate Success and Error case suites, verifying correct model invocation, logging behavior, error message mapping, and response handling for notFound, unauthorized, tooSoon, and unexpected status scenarios.
Middleware Validation Tests
test/unit/middlewares/application-validator.test.ts
Renamed existing feedback validation test suite and added new validateApplicationUpdateData test suite covering allowed fields, URI validation, nested objects, length constraints, numeric bounds, phoneNo trimming, and validation failure paths. Two new validator methods added.
Model Unit Tests
test/unit/models/application.test.ts
New ApplicationModel.updateApplication test suite verifying successful updates, notFound when application missing, unauthorized when userId mismatches, and tooSoon conflicts for updates within 24 hours.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • iamitprakash

Poem

🐰 Hop, hop, hooray! Tests multiply,
PATCH endpoints now verified and spry,
Authorization guards and edit delays too,
Validation rules in triplicate—we're through!
Coverage blooms like spring carrots anew! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test: implement tests for application update functionality' is clear, concise, and directly describes the primary change—adding comprehensive tests for application update functionality across multiple test layers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is clearly related to the changeset, detailing the addition of comprehensive test coverage for application update functionality across integration, controller, validation, and model layers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch anuj/application-edit-test

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AnujChhikara AnujChhikara changed the title feat: implement comprehensive tests for application update functionality test: implement tests for application update functionality Feb 3, 2026
@MayankBansal12
Copy link
Member

@coderabbitai bro review, please go easy on @AnujChhikara

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

@MayankBansal12, absolutely! I'll review the PR with a constructive approach. Great to see the focus on test coverage for the application update functionality - the screenshots show solid coverage numbers!

Let me dive into the changes and provide helpful feedback. 🚀

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@test/integration/application.test.ts`:
- Around line 359-427: The tests mutate applicationId1 in the first "should
return 200..." case which sets lastEditAt and causes later PATCH validation
tests to get 409 Conflict; fix by isolating tests—either create a fresh
application for each PATCH test or switch the validation tests to use a
different pre-seeded app (e.g., applicationId2 with superUserJwt), update the
tests in the "PATCH /applications/:applicationId" describe block to use the new
application id or create a new application within each it() before sending the
PATCH so the 24-hour edit restriction does not interfere.

MayankBansal12
MayankBansal12 previously approved these changes Feb 5, 2026
Base automatically changed from anuj/application-edit-functionality to develop February 10, 2026 20:33
@iamitprakash iamitprakash dismissed MayankBansal12’s stale review February 10, 2026 20:33

The base branch was changed.

@iamitprakash iamitprakash merged commit c775258 into develop Feb 11, 2026
4 checks passed
@iamitprakash iamitprakash deleted the anuj/application-edit-test branch February 11, 2026 18:52
@AnujChhikara AnujChhikara mentioned this pull request Feb 11, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants